import { Component, ChangeDetectorRef, Inject } from '@angular/core';
import { IonicPage, NavParams, NavController } from 'ionic-angular';

// service
import { HideBarsService } from '../../../providers/utils/hideBars.service';
import { BorrowService } from '../../../providers/service/borrow.service';
/**
 * 借款申请
 */
@IonicPage()
@Component({
  selector: 'page-borrow-apply',
  templateUrl: 'borrow-apply.html'
})
export class BorrowApplyPage{

  // 用户信息
  private loanDetails: any;

  private checked: boolean= true;
  // 若下来未完成不能点击下一步

  constructor(
    private navCtrl: NavController,
    private navParams: NavParams,
    private hideBars: HideBarsService,
    private borrowService: BorrowService,
    private ref: ChangeDetectorRef,
    @Inject('user') private userService,
  )
  {
    this.loanDetails= this.navParams.get('data');
  }


  /*** 页面进入
   * */
  ionViewWillEnter()
  {
    this.hideBars.changeTabBarsElementBottom('-5rem');
  }


  /*** 页面离开
   * */
  ionViewWillLeave()
  {
    this.hideBars.changeTabBarsElementBottom('0');
  }

  /*** 执行点击
  * */
  executeChecked()
  {
    this.checked= !this.checked;
    this.ref.detectChanges();
  }

  /** 执行申请
   */
  public executeApply(): void
  {
    this.borrowService.getBorrowApply(this.loanDetails, this.navCtrl);
  }

}

